package com.zh.core.service.impl;

import com.zh.core.dao.UserDao;
import com.zh.core.entity.User;
import com.zh.core.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhaohui on 2019/8/4
 * Description:
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;

    @Override
    public int createUser(User user) {
        return userDao.createUser(user);
    }

    @Override
    public int deleteUser(String username) {
        return userDao.deleteUser(username);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public List<User> queryAllUser() {
        return userDao.queryAllUser();
    }

    @Override
    public User queryUserByUsername(String username) {
        return userDao.queryUserByUsername(username);
    }

    @Override
    public List<User> queryUserByPhone(String phone) {
        return userDao.queryUserByPhone(phone);
    }

    @Override
    public List<User> queryUserByEmail(String email) {
        return userDao.queryUserByEmail(email);
    }

    @Override
    public boolean usernameExist(String username) {
        return userDao.queryUserByUsername(username) != null;
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        return userDao.queryUserByUsernameAndPassword(username, password);
    }
}
